﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Reflection;
using System.IO;

namespace MethodWorx.Core.Extensions
{
    public static class AssemblyExtensions
    {
        public static string GetResourceString(this Assembly asm, string name)
        {
            using(StreamReader reader = new StreamReader(asm.GetManifestResourceStream(name)))
            {
                return reader.ReadToEnd();
            }
        }

        public static byte [] GetResource(this Assembly asm, string name)
        {
            using (Stream stream = asm.GetManifestResourceStream(name))
            {
                byte [] buffer = new byte[stream.Length];
                stream.Read(buffer, 0, buffer.Length);

                return buffer;
            }
        }
    }
}
